#include "orangepch.h"

#include "Core/Input.h"
#include "Core/Application.h"
#include "GLFW/glfw3.h"
namespace Orange {
	
	bool Input::isKeyPressed(int keycode)  {

		auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());

		int state = glfwGetKey(window, keycode);

		return state == GLFW_PRESS || state == GLFW_REPEAT;
	}
	bool Input::isMouseButtonPressed(int button) 
	{

		auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());

		int state = glfwGetMouseButton(window, button);

		return state == GLFW_PRESS;
	}
	std::pair<float, float> Input::GetMousePos() 
	{
		auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());

		double x, y;
		glfwGetCursorPos(window, &x, &y);

		return {(float)x,(float)y};
	}
	float Input::GetMousePosX() 
	{
		auto[x,y]= GetMousePos();
		return x;
	}
	float Input::GetMousePosY() 
	{
		auto [x, y] = GetMousePos();
		return y;
	}
}